#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

using namespace std;

#include "string.h"

//using namespace bit;


//int main()
//{	
//	//string a;
//	//string b;
//	//swap(a, b);
//	test_string9();
//
//	return 0;
//}

class Solution {
public:
    string reverseWords(string s) {
        size_t pos = s.find(' ');

        size_t start = 0;
        while (pos != string::npos)
        {
            reverse(start + s.begin(), pos + s.begin());
            start = pos + 1;

            pos = s.find(' ', start);
        }

        reverse(start + s.begin(), s.end());

        return s;

    }
};

int main()
{
    string s("Let's take LeetCode contest");
 
    string s1 = Solution().reverseWords(s);

    cout << s1 << endl;
}